package cn.dt.person.controller;

import cn.dt.person.pojo.Person;
import cn.dt.person.service.PersonService;
import io.swagger.annotations.*;
import io.swagger.models.auth.In;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Api(tags = "人员相关接口",description = "提供出库的Resut API")
public class PersonController {
    @Resource
    PersonService service;

    @ApiOperation("查询全部人员信息")
    @PostMapping("/query/personlist")
    public List<Person> getSelectList(){
        return service.getSelectPersonlist();
    }
    @ApiOperation("根据id删除人员信息")
    @GetMapping("/del/by/id")
    @ApiImplicitParam(name = "id",value =" 人员id",dataType = "Integer")
    public int getDelByid(Integer id){
        return service.getDelPerson(id);
    }


    @ApiOperation("添加出库信息")
    @PostMapping("/add/person")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name",value = "姓名",dataType = "String"),
            @ApiImplicitParam(name = "gender",value = "性别",dataType = "int"),
            @ApiImplicitParam(name = "age",value = "年龄",dataType = "int"),
            @ApiImplicitParam(name = "rank",value = "等级",dataType = "int"),
            @ApiImplicitParam(name = "department",value = "部门",dataType = "String")
    })
    public int getAdd(String name,Integer gender,Integer age,Integer rank,String department){
        Person person=new Person();
        person.setRank(rank);
        person.setName(name);
        person.setGender(gender);
        person.setDepartment(department);
        person.setAge(age);
        return service.getAddPerson(person);
    }
}
